package com.rp.common.utils;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * 类说明:获取密码加密
 *
 * @author ****
 * @date 2020-11-27 15:34  新建
 */

public class Md5PassWordUtil {
    /**
     * @Author HuJingYu
     * @Date 16:28 2020-11-27
     * @Description 获取shiroMD5加密后的密码
     * @param password 初始密码
     * @param salt  密码盐
     * @param hashIterations    加密次数
     * @return java.lang.String
     */
    public static final String getMd5(String password,String salt,Integer hashIterations){
        String hashAlgorithmName = "MD5";
        ByteSource byteSalt = ByteSource.Util.bytes(salt);
        Object source = password;
        SimpleHash result = new SimpleHash(hashAlgorithmName,source,byteSalt,hashIterations);
        return result.toString();
    }

}
